<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
		<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
		<title>支付页</title>
		<link rel="icon" href="http://static.xiaohong.work/img/favicon.ico">


    <link rel="stylesheet" type="text/css" href="http://static.xiaohong.work/css/all.css" />
    <link rel="stylesheet" type="text/css" href="http://static.xiaohong.work/css/pages-pay.css" />
</head>

	<body>
		<!--head-->
		<!-- 头部栏位 -->
	    <!--页面顶部-->
		<top/>

		<div class="cart py-container" id="app">


			<!--主内容-->
			<div class="checkout py-container  pay">
				<div class="checkout-tit">
					<h4 class="tit-txt"><span class="success-icon"></span><span  class="success-info">订单提交成功，请您及时付款，以便尽快为您发货~~</span></h4>
					<div class="paymark">
						<span class="fl">请您在提交订单<em class="orange time">10分钟</em>之内完成支付，超时订单会自动取消。订单号：<em v-text="order.sn"></em></span>
						<span class="fr"><em class="sui-lead">应付金额：</em><em  class="orange money">￥<span v-text="order.totalMoney"></span></em></span>
					</div>
				</div>

				<div class="check-info">
					<h4>重要说明：</h4>
					<ol>
						<li>小鸿商城支付平台目前支持<span class="zfb">支付宝</span>支付方式。</li>
						<li>其它支付渠道正在调试中，敬请期待。</li>
						<li>为了保证您的购物支付流程顺利完成，请保存以下支付宝信息。</li>
					</ol>
					<h4>支付宝账户信息：（很重要，<span class="save">请保存！！！</span>）</h4>
					<ul>
						<li>支付帐号：jiulrt3062@sandbox.com</li>
						<li>密码：111111</li>
						<li>支付密码：111111</li>
					</ul>
				</div>


				<div class="checkout-steps">
					<!--收件人信息-->
					<div class="step-tit">
						<h5>支付平台</h5>
					</div>
					<div class="step-cont">
						<ul class="payType">
							<li @click="order.payType=1" :style="order.payType == 1 ? 'border: red 1px solid' : ''"><img src="http://static.xiaohong.work/img/_/pay1.jpg"></li>
							<li @click="order.payType=2" :style="order.payType == 2 ? 'border: red 1px solid' : ''"><img src="http://static.xiaohong.work/img/_/pay2.jpg"></li>
							<li @click="order.payType=3" :style="order.payType == 3 ? 'border: red 1px solid' : ''"><img src="http://static.xiaohong.work/img/_/pay3.jpg"></li>
							<li @click="order.payType=4" :style="order.payType == 4 ? 'border: red 1px solid' : ''"><img src="http://static.xiaohong.work/img/_/pay4.jpg"></li>
							<li @click="order.payType=5" :style="order.payType == 5 ? 'border: red 1px solid' : ''"><img src="http://static.xiaohong.work/img/_/pay5.jpg"></li>

						</ul>

					</div>
					<div class="hr"></div>

					<!--支付和送货-->
					<div class="payshipInfo">
						<div class="step-tit">
							<h5>支付网银</h5>
						</div>
						<div class="step-cont">
							<ul class="payType">
								<li><img src="http://static.xiaohong.work/img/_/pay10.jpg"></li>
								<li><img src="http://static.xiaohong.work/img/_/pay11.jpg"></li>
								<li><img src="http://static.xiaohong.work/img/_/pay12.jpg"></li>
								<li><img src="http://static.xiaohong.work/img/_/pay13.jpg"></li>
								<li><img src="http://static.xiaohong.work/img/_/pay14.jpg"></li>
								<li><img src="http://static.xiaohong.work/img/_/pay15.jpg"></li>
								<li><img src="http://static.xiaohong.work/img/_/pay16.jpg"></li>
								<li><img src="http://static.xiaohong.work/img/_/pay17.jpg"></li>
								<li><img src="http://static.xiaohong.work/img/_/pay18.jpg"></li>
								<li><img src="http://static.xiaohong.work/img/_/pay19.jpg"></li>
								<li><img src="http://static.xiaohong.work/img/_/pay20.jpg"></li>
								<li><img src="http://static.xiaohong.work/img/_/pay21.jpg"></li>
								<li><img src="http://static.xiaohong.work/img/_/pay22.jpg"></li>

							</ul>
						</div>
						<div class="hr"></div>
					</div>

					<div class="submit sui-text-center" @click="pay">
						<a class="sui-btn btn-danger btn-xlarge" target="_blank">立即支付</a>
					</div>
					<div class="otherpay">
						<div class="step-tit">
							<h5>其他支付方式</h5>
						</div>
						<div class="step-cont">
							<span><a href="weixinpay.html" target="_blank">微信支付</a></span>
							<span>中国银联</span>
						</div>
					</div>
				</div>
			</div>

		</div>
		<!-- 底部栏位 -->
		<!--页面底部-->
		<end/>
		<!--页面底部END-->

		<!-- 引入组件库 -->
		<script src="https://cdn.jsdelivr.net/npm/vue@2.6.8/dist/vue.js"></script>
		<script src="http://static.xiaohong.work/js/axios.min.js"></script>
		<script src="http://static.xiaohong.work/js/common.js"></script>
		<script>
			new Vue({
				el: '#app',
				data() {
					return {
						order: {
							sn: '',
							totalMoney: 0,
							payType: 2
						}
					}
				},
				created: function () {
					this.getOrder();
				},
				methods: {
					getOrder(){
						// 获取地址中的id
						var id = xiaohong.getUrlParam("orderId");
						// 查询订单
						xiaohong.http.get('/order/'+id).then(async resp => {
							if(resp.data.code === 20000){
								this.order.sn = resp.data.data.id;
								this.order.totalMoney = resp.data.data.totalMoney;
							}else {
								alert(resp.data.message)
							}
						}).catch(() => alert('获取购物车失败'));
					},
					async pay(){
						// 发起支付
						window.location = 'http://gateway.xiaohong.work/api/pay/zfbPay/pay?sn='
								+this.order.sn+"&token="+window.localStorage.getItem("accessToken");
					}
				},
				watch:{
					allCheck(newVal){
						if (newVal){
							this.choiceList = this.shopcarlist;
							xiaohong.store.set("Cars",this.choiceList);
							this.sum = 0;
							this.paySum = 0;
							for (let i = 0; i <this.choiceList.length; i++) {
								this.sum += this.choiceList[i].money;
								this.paySum += this.choiceList[i].payMoney;
							}
						}else{
							if(this.unCheck_flag){
								this.choiceList = [];
								xiaohong.store.set("Cars",this.choiceList);
								this.sum = 0;
								this.paySum = 0;
							}else {
								this.sum = 0;
								this.paySum = 0;
								xiaohong.store.set("Cars",this.choiceList);
								for (let i = 0; i <this.choiceList.length; i++) {
									this.sum += this.choiceList[i].money;
									this.paySum += this.choiceList[i].payMoney;
								}
							}
						}

					},
					choiceList(newVal){
						// newVal === this.shopcarlist 好像有bug,即使一样了也没反应。。。
						if (newVal.length !== this.shopcarlist.length){
							this.unCheck_flag = false;
							this.allCheck = false;
						}else {
							this.unCheck_flag = true;
							this.allCheck = true;
						}
						this.sum = 0;
						this.paySum = 0;
						xiaohong.store.set("Cars",this.choiceList);
						for (let i = 0; i <this.choiceList.length; i++) {
							this.sum += this.choiceList[i].money;
							this.paySum += this.choiceList[i].payMoney;
						}

					}
				},
				components: {
					top: () => import("http://static.xiaohong.work/js/pages/top.js"),
					end: () => import("http://static.xiaohong.work/js/pages/end.js")
				}
			})
		</script>

</body>

</html>
